<?php

/**
 * Created by IntelliJ IDEA.
 * User: jimmyhsu
 * Date: 2017/4/23
 * Time: 12:24
 */
require_once '../AipFace.php';
class bdaip {
    const APP_ID = '9473811';
    const API_KEY = 'dPu40ry5GmFs30HzGlCvVDca';
    const API_SECRET = 'VdQgKWKv81yTt00xRKm4C4zAIrGY74S8';
    var $aipFace;

    public function __construct(){
        $this->aipFace = new AipFace($this::APP_ID, $this::API_KEY, $this::API_SECRET);
    }

    public function addToGroup($userid, $gid) {
        return $this->aipFace->addGroupUser($gid, $userid);
    }

    public function removeGroup($gid) {
        $userResult = $this->aipFace->getGroupUsers($gid);
        $users = $userResult['result'];
        foreach ($users as $user) {
            $this->aipFace->deleteGroupUser($gid, $user['uid']);
        }
    }

}